﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Htse.Blue.Models
{
	public class PagedList<T> : List<T>
	{
		public int PageIndex { get; set; }
		public int PageSize { get; set; }
		public string SortExpression { get; set; }
		public int TotalItemCount { get; set; }
		public int TotalPageCount { get; private set; }
		public string Filter { get; set; }

		public PagedList(
			IEnumerable<T> items,
			int pageIndex,
			int pageSize,
			int totalItemCount,
			string sortExpression)
			: this(items, pageIndex, pageSize, totalItemCount, sortExpression, null)
		{
			
		}

		public PagedList(
			IEnumerable<T> items,
			int pageIndex,
			int pageSize, 
			int totalItemCount,
			string sortExpression,
			string filter)
		{
			AddRange(items);
			PageIndex = pageIndex;
			PageSize = pageSize;
			SortExpression = sortExpression;
			TotalItemCount = totalItemCount;
			TotalPageCount = (int)Math.Ceiling(totalItemCount / (double)pageSize);
			Filter = filter;
		}
	}  
}
